package com.sxkiler.demo.controller;

import com.sxkiler.demo.utils.ResUtils;
import com.sxkiler.demo.vo.ResVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system")
public class SystemGcController {

    @RequestMapping("/simpleGc")
    public ResVo simpleGc(){
        return ResUtils.success();
    }

    @RequestMapping("/monitoring")
    public ResVo monitoring(){
        System.out.print("====system.monitoring====");
        return ResUtils.success();
    }


    @RequestMapping("/mock")
    public ResVo mock(
            @RequestParam(name = "times")
            String times,
            @RequestParam(name = "timeout")
            String timeout) throws Exception{
        Integer timesV = Integer.parseInt(times);
        Long timeoutV = Long.parseLong(timeout);
        for(int i=0;i<timesV;i++){
            System.out.println("sleep_times_"+i+"_"+timeoutV+"_ms");
            Thread.sleep(timeoutV);
        }
        return ResUtils.success();
    }

}
